home *** CD-ROM | disk | FTP | other *** search
- Path: engnews1.Eng.Sun.COM!taumet!clamage
- From: "Bradd W. Szonye" <bradds@ix.netcom.com>
- Newsgroups: comp.std.c++
- Subject: Why no standard classes to cope with times?
- Date: 21 Apr 1996 15:33:38 GMT
- Organization: Netcom
- Approved: clamage@eng.sun.com (comp.std.c++)
- Message-ID: <01bb2ee6.7fd76940$65c2b7c7@Zany.localhost>
- NNTP-Posting-Host: taumet.eng.sun.com
- X-Nntp-Posting-Host: det-mi3-05.ix.netcom.com
- X-Netcom-Date: Sat Apr 20 1:23:05 PM CDT 1996
- X-Newsreader: Microsoft Internet News
- Content-Length: 1698
- Originator: clamage@taumet
-
- I have been perusing the DWP and have found nothing added to the Standard
- C Library for coping with times, in particular a method for computing a
- new time by adding an offset to a known time or finding the difference
- between two times.
-
- The standard mktime() almost does this well already. The fact that a
- "suitable" method already exists is probably why nothing was added to the
- standard. However, string<> was added to standardize the many differing
- implementations of strings. Lots of vendors provide a custom date/time
- object too; why were these classes not also standardized?
-
- The particular problem I run into has to do with daylight savings time. In
- places where DST is an issue, there's typically one day of the year that
- has two ranges of time from 1am to 2am and another day of the year where
- that time range doesn't exist. The standard doesn't seem to address this
- issue well. Suppose I use mktime() to create "The first Sunday in April at
- 1:30am"? Where I live, that time doesn't exist. What does mktime() create?
- Or "The first Sunday in November at 1:30am"? Where I live, there are two
- possible interpretations of that.
-
- Even worse, suppose I have a struct tm containing "The day before daylight
- savings time begins at 12pm." When I add 24 hours to tm_hours and set
- tm_isdst to -1, what does mktime() create? The next day at 12pm, 1pm, or
- 11am? Daylight savings time or not? Which semantics I want probably
- depends on whether I'm trying to calculate "1 day from now" or "24 hours
- from now."
-
- There has to be some reasonable answer to these questions; why doesn't the
- standard address it? Or am I just missing something?
-
- --
- Bradd W. Szonye
- Doubleplus Corporation
- bradds@ix.netcom.com
-
-
-
- [ comp.std.c++ is moderated. To submit articles: try just posting with ]
- [ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
- [ FAQ: http://reality.sgi.com/employees/austern_mti/std-c++/faq.html ]
- [ Policy: http://reality.sgi.com/employees/austern_mti/std-c++/policy.html ]
- [ Comments? mailto:std-c++-request@ncar.ucar.edu ]
-